package com.itheima.demo1create;

public class ThreadDemo2 {
    public static void main(String[] args)
    {
//        目标：创建方式2：通过实现Runnable接口
//        创建线程任务的对象代表一个线程任务
        Runnable mr=new MyRunnable();
        new Thread(mr,"线程一").start();
        for (int i = 0; i < 10; i++)
        {
            System.out.println("主线程输出："+i);
        }
    }
}
class MyRunnable implements Runnable{
    @Override
    public void run()
    {
        for (int i = 0; i < 10; i++)
        {
            System.out.println(Thread.currentThread().getName()+"输出："+i);
        }
    }
}
